//
//  YSAlertsViewController.m
//  YSKitDemo
//
//  Created by Kyson on 2018/9/12.
//  Copyright © 2018年 YangShen. All rights reserved.
//

#import "YSAlertsViewController.h"
#import "YSAlertAction.h"

@interface YSAlertsViewController ()

@end

@implementation YSAlertsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.items = @[ [YSDemoItem itemWithTitle:@"Alert 1 Button"        aClass:nil],
                    [YSDemoItem itemWithTitle:@"Alert 2 Button"        aClass:nil],
                    [YSDemoItem itemWithTitle:@"Alert 3 Button"        aClass:nil],
                    [YSDemoItem itemWithTitle:@"AlertSheet 1 Button"   aClass:nil],
                    [YSDemoItem itemWithTitle:@"AlertSheet 2 Button"   aClass:nil],
                    [YSDemoItem itemWithTitle:@"AlertSheet 3 Button"   aClass:nil],
                    ].mutableCopy;
    
    UIAlertView *alert =  [[UIAlertView alloc] initWithTitle:@"title" message:@"messgae" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"确认", nil];
    [alert show];
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    NSString *title = @"I am title";
    NSString *message = @"message  message";
    NSString *cancelButton = @"取消";
    
    if (indexPath.row == 0) {
        [YSAlertAction showAlertWithTitle:title message:message cancelButtonTitle:cancelButton buttonIndexBlock:nil otherButtonTitles:nil];
    } else if (indexPath.row == 1) {
        [YSAlertAction showAlertWithTitle:title message:message cancelButtonTitle:cancelButton buttonIndexBlock:^(NSInteger buttonIndex) {
            NSLog(@"%zd", buttonIndex);
        } otherButtonTitles:@"确定", nil];
    } else if (indexPath.row == 2) {
        [YSAlertAction showAlertWithTitle:title message:message cancelButtonTitle:cancelButton buttonIndexBlock:^(NSInteger buttonIndex) {
            NSLog(@"%zd", buttonIndex);
        } otherButtonTitles:@"确定1", @"确定2", nil];
    }
    
    else if (indexPath.row == 3) {
        [YSAlertAction showAlertSheetWithTitle:title message:message cancelButtonTitle:cancelButton buttonIndexBlock:nil otherButtonTitles:nil];
    } else if (indexPath.row == 4) {
        [YSAlertAction showAlertSheetWithTitle:title message:message cancelButtonTitle:cancelButton buttonIndexBlock:^(NSInteger buttonIndex) {
            NSLog(@"%zd", buttonIndex);
        } otherButtonTitles:@"确定", nil];
    } else if (indexPath.row == 5) {
        [YSAlertAction showAlertSheetWithTitle:title message:message cancelButtonTitle:cancelButton buttonIndexBlock:^(NSInteger buttonIndex) {
            NSLog(@"%zd", buttonIndex);
        } otherButtonTitles:@"确定1", @"确定2", nil];
    }
    
}

@end
